#include "Address.h"


Address::Address(){
	
}

Address::Address(string locality, string street, unsigned short doorNumber, PostalCode &postalCode) {
    setLocality(locality);
    setStreet(street);
    setDoorNumber(doorNumber);
    setPostalCode(postalCode);
}

Address::~Address(){

}


string Address::getLocality() const {
    return locality;
}

//TODO: must only contain normal characters (no numbers and no symbols - except .(dot)) Capitalize all initial letters. Limit lenght to 30
void Address::setLocality(string locality){
    this->locality = locality;
}

string Address::getStreet() const {
    return street;
}

//TODO: first letter cannot be a number or symbol. Limit lenght to 100
void Address::setStreet(string street){
    this->street = street;
}


unsigned short Address::getDoorNumber() const {
    return doorNumber;
}


void Address::setDoorNumber(unsigned short doorNumber){
    this->doorNumber = doorNumber;
}


PostalCode *Address::getPostalCode(){
    return postalCode;
}


void Address::setPostalCode(PostalCode &postalCode){
    this->postalCode = &postalCode;
}

string Address::printAddres() {
    stringstream info;

    info << this->getLocality() << ", " << this->getStreet() << " street, number"
            << this->getDoorNumber() << endl << this->getPostalCode().printPostalCode() << endl;
    
    return info.str();
}

void Address::newAddress (Address &address) {
    string locality, street;
    unsigned short doorNumber;

    cout << "Locality: ";
    cin >> locality;

    cout << "Street: ";
    cin >> street;

    cout << "Door Number: ";
    cin >> doorNumber;

    cout << "Postal Code: ";
    postalCode.newAddress(address.getPostalCode());

    address.setDoorNumber(doorNumber);
    address.setLocality(locality);
    address.setStreet(street);
}
